1840B - Binary Cafe - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

/*कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥
Karmanye vadhikaraste Ma Phaleshu Kadachana
Ma Karmaphalaheturbhurma Te Sangostvakarmani,
The meaning of the verse is :—
You have the right to work only but never to its fruits.
Let not the fruits of action be your motive, nor let your attachment be to
inaction*/
#include <bits/stdc++.h>
using namespace std;
#define pi (3.141592653589)
#define mod 1000000007
#define pb push_back
#define is insert
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rfr(n) for(int i=n-1;i>=0;i--)
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define fr(n) for(long long i=0;i<n;i++)
#define nesfr(x,y) for(long long i=0;i<x;i++)for(long long j=0;j<y;j++)
#define rep(i,a,b) for(long long i=a;i<b;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
#define nl cout << 
 
#define vvi vector<vector<ll>>
#define vvc vector<vector<char>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vc vector<char>
const unsigned int M = 1000000007;
const int  N = 2e5 + 5 ;
int gcd(int a,int b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
int lcm(int a, int b) {
return (a * b) / gcd(a, b);
}
static bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
return (a.first < b.first || (a.first==b.first && a.second > b.second )) ;
}
bool is_set(unsigned int number, int x)
{
return (number >> x) & 1;
}
bool isPowerOfTwo(unsigned int n)
 {
return n && !(n & (n - 1));
}
int countSetBits(int n)
{
int count = 0;
while (n)
{
n = n & (n - 1);
count++;
}
return count;
}
int fib(int n) {
int a = 0;
int b = 1;
for (int i = 0; i < n; i++) {
int tmp = a + b;
a = b;
b = tmp;
}
return a;
}
int parent[200005];
int sizes[200005];
void make_set(int n) {
rep(i,1,n+1){
parent[i] = i;
sizes[i] = 1;
}
}
int find_set(int v) {
if (v == parent[v])
return v;
return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
 a = find_set(a);
b = find_set(b);
if (a != b) {
if (sizes[a] < sizes[b])
swap(a, b);
parent[b] = a;
sizes[a] += sizes[b];
 }
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll mx;
    if(k>63){
        mx=INT64_MAX;
    }
    else{
        mx=pow(2,k);
    }
    cout<<min(n+1,mx)<<endl;

}
int main(){
fast;
ll t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}


Comments

Submit
0 Comments
More Questions

320A - Magic Numbers
1658A - Marin and Photoshoot
514A - Chewbaсca and Number
382A - Ksenia and Pan Scales
734B - Anton and Digits
1080A - Petya and Origami
1642D - Repetitions Decoding
1440A - Buy the String
1658F - Juju and Binary String
478A - Initial Bet
981A - Antipalindrome
365A - Good Number
1204B - Mislove Has Lost an Array
1409D - Decrease the Sum of Digits
1476E - Pattern Matching
1107A - Digits Sequence Dividing
1348A - Phoenix and Balance
1343B - Balanced Array
1186A - Vus the Cossack and a Contest
1494A - ABC String
1606A - AB Balance
1658C - Shinju and the Lost Permutation
1547C - Pair Programming
550A - Two Substrings
797B - Odd sum
1093A - Dice Rolling
1360B - Honest Coach
1399C - Boats Competition
1609C - Complex Market Analysis
1657E - Star MST